//
//  PKProductMianListTableViewCell.m
//  PianKe
//
//  Created by ybq on 15/12/22.
//  Copyright © 2015年 B7_Young. All rights reserved.
//

#import "PKProductMianListTableViewCell.h"

@implementation PKProductMianListTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 图片宽高比 608 : 300
        _mainImageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, 10, kWidth - 40, (kWidth - 40) * 300 / 608)];
        [self.contentView addSubview:_mainImageView];
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, _mainImageView.frame.size.height + 10 + 10, 250, 20)];
        [self.contentView addSubview:_titleLabel];
        _button = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _button.frame = CGRectMake(kWidth - 70, _titleLabel.frame.origin.y, 60, 25);
        _button.backgroundColor = [UIColor colorWithRed:100.0 / 255 green:170.0 / 255 blue:55.0 / 255 alpha:1];
        _button.layer.cornerRadius = 10;
        _button.titleLabel.font = [UIFont systemFontOfSize:12];
        [_button setTitle:@"立即购买" forState:(UIControlStateNormal)];
        [self.contentView addSubview:_button];
    }
    return self;
}
- (void)setModel:(PKProductMainListModel *)model {
    _model = model;
    _titleLabel.text = model.title;
    // 同步的方式显示,会用SD代替
//    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:model.coverimg]];
    [_mainImageView sd_setImageWithURL:[NSURL URLWithString:model.coverimg] placeholderImage:nil];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
